<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: wg
  Date: 2017/10/12
  Time: 8:57
--%>
<%@ page contentType="text/html;charset=UTF-8" errorPage="name.jsp" isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <h1>Hello world Jsp</h1>
    <p>the jsp 本质上 is Servlet</p>
    <%
        int i = 0;
        for (i = 0; i < 10; i++) {
    %>
        <p> Hell world</p>
        <%--<%@include file="name.jsp"%>--%>
    <%
        }
    %>

    <%
        i = 4;
        System.out.println(x);
//        int x = 1 / 0;
    %>
    <%!
        private int x = 3;
        private String y = "hello world";
    %>
    <%=x+3%>

    <%
        for (i = 0; i < 10; i++) {
          out.write("hello world");
        }
    %>

    <table border="1">
        <tr>
            <th>名字</th>
            <th>学号</th>
        </tr>

        <%
            for (i = 0; i < 10; i++) {
              out.write("<tr>");
              out.write("<td>" + i + "</td>");
              out.write("<td>" + i + "</td>");
              out.write("</tr>");
            }

            ServletContext ctx = ((HttpServlet)page).getServletContext();
            out.write((String)ctx.getAttribute("name"));
            out.write(request.getParameter("name"));
            out.write((String)application.getAttribute("name"));
            out.write("<br>");
        %>
    </table>

    <%
        // key = value
        pageContext.setAttribute("page", "PAGE_SCOPE");
        pageContext.setAttribute("request", "REQUEST_SCOPE", pageContext.REQUEST_SCOPE);
        pageContext.setAttribute("session", "SESSION_SCOPE", pageContext.SESSION_SCOPE);
        pageContext.setAttribute("context", "CONTEXT_SCOPE", pageContext.APPLICATION_SCOPE);
        // key = value
        System.out.println(pageContext.getAttribute("page"));
        System.out.println(pageContext.getAttribute("request", pageContext.REQUEST_SCOPE));
        System.out.println(pageContext.getAttribute("session", pageContext.SESSION_SCOPE));
        System.out.println(pageContext.getAttribute("context", pageContext.APPLICATION_SCOPE));
        pageContext.forward("/name.jsp");
    %>
    <a href="name.jsp">转</a>
</body>
</html>
